package com.lk.util;

import com.lk.constant.RedisConst;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.HashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

/**
 * @author : lk
 * @date 2021/11/10 13:48
 * @description : TODO
 * @since 1.0
 **/
@Component
public class RedisUtil {


    @Autowired
    private RedisTemplate<String, Object> redisTemplate;
    private HashOperations<String, String, Object> hashOperations = redisTemplate.opsForHash();

    /**
     * 获取到全局的rabbitmq 的id
     *
     * @return
     */
    public String getMessageId() {
        return String.valueOf(hashOperations.get(RedisConst.RABBITMQ_MESSAGE, RedisConst.MESSAGE_ID));
    }


    public void put(Object data) {
        hashOperations.put(RedisConst.RABBITMQ_MESSAGE, RedisConst.MESSAGE_ID, data);
    }


}
